package com.hh.hot100;

import java.util.ArrayList;

/**
 * @Author hanghao
 * @Date 2023/6/27 14:19
 * @Version 1.0
 * easy
 * 回文链表
 */

public class No234 {
    public boolean isPalindrome(ListNode head) {
        ArrayList<Integer> list = new ArrayList<>();
        ListNode cur = head;
        while(cur != null) {
            list.add(cur.val);
            cur = cur.next;
        }
        int left = 0;
        int right = list.size() - 1;
        while(left < right) {
            if(!list.get(left).equals(list.get(right))) {
                return false;
            }
            left++;
            right--;
        }
        return true;
    }
}
